﻿<style type="text/css">
    .paging
    {
        overflow:auto;
        background-color:Gray;
        clear:both
    }
    
    .paging .lister
    {
        float:right;
        margin-right:20px;
        overflow:hidden;
    }
    .paging .lister li a,.paging .lister li a:active,.paging .lister li a:visited
    {
        float:left;
        padding:10px;
        font-size:16px;
        cursor:pointer;
        font-weight:bold;
        color:blue;
        
    }
    .paging .lister li
    {
        list-style:none;
        float:left;
    }
    .paging .lister li a:hover,.paging .lister li a.active
    {
        float:left;
        background-color:Orange;
        color:Black;
    }
</style>
<div class="paging">
    <ul class="lister">
    
        @{
            MDF.Utilites.Tools.Pagging pagging = ViewBag.Pagging;
            if (pagging.IsUssing == true && pagging.TotalPage!=1)
            {
                var action = ViewContext.RouteData.Values["action"].ToString();
                var controller = ViewContext.RouteData.Values["controller"].ToString();
                <li style="padding-top:13px;"><b>Page: </b></li>
                int iStart = 1;
                int iEnd = pagging.TotalPage;
                if (pagging.CurrentPage > 5)
                {
                    iStart = pagging.CurrentPage - 5;
            <text>
            <li><a href="@pagging.Link 1">1</a></li>
            <li><a href="#">...</a></li>
            </text>
                }

                if (pagging.TotalPage > pagging.CurrentPage + 5)
                {
                    iEnd = pagging.CurrentPage + 5;
                }
                for (int i = iStart; i <= iEnd; i++)
                {
                    string link = "/"+controller +"/"+ action+"/"+ i;
                    if (pagging.CurrentPage == @i)
                    {
            <li><a class="active" href="#">@i</a></li>
                    }
                    else
                    {
                        
            <li><a href="@link">@i</a></li>
                    }
                }
                if (pagging.TotalPage > pagging.CurrentPage + 5)
                {
            <text>
            <li><a href="#">...</a></li>
            <li><a href="@pagging.Link @pagging.TotalPage">@pagging.TotalPage</a></li>
            </text>
                }
            }
        }
    </ul>
</div>
